#!/bin/sh
cd `dirname $0`
cd ..

# $ANDROID_PROJECT_ONE_PATH 环境变量：项目Root路径
# 示例: 编辑 .bash_profile 添加环境变量配置
# export ANDROID_PROJECT_DEMO_PATH=/Users/qimao/workspace/Flutter/flutter/AndroImagePreviewHost
ANDROID_PROJECT_FLUTTER_DIR="$ANDROID_PROJECT_DEMO_PATH/flutter"
# Flutter构建产物目录
ANDROID_BUILD_DIR="./build/host/outputs/repo"

# 删除Flutter/repo文件夹产物
rm -rf -- "$ANDROID_PROJECT_FLUTTER_DIR/repo"

# 构建Flutter AAR
flutter build aar

# 拷贝新产物到七猫工程目录
if [ ! -d "$ANDROID_PROJECT_FLUTTER_DIR" ]; then
    echo -e "\033[31m警告: 主工程目标路径 $ANDROID_PROJECT_FLUTTER_DIR 不存在。\033[0m"
else
    cp -r "$ANDROID_BUILD_DIR" "$ANDROID_PROJECT_FLUTTER_DIR"
    echo "\033[31m提示: 拷贝新产物到主工程目标路径 $ANDROID_PROJECT_FLUTTER_DIR 完成。\033[0m"
fi